<template>
  <div class="table-page-search-wrapper">
    <el-form :inline="true" :model="form" ref="form">
      <el-row :gutter="24">
        <el-col :span="5">
          <el-form-item label="供应商" prop="supplierCode">
            <supplier-select v-model="form.supplierCode" @select="handleSelect" />
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="姓名" prop="linkmanName">
            <el-input
              clearable
              @keyup.native.enter="handleSearch"
              v-model="form.linkmanName"
              placeholder="请选择"
            />
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="手机号" prop="linkmanTel">
            <el-input
              @keyup.native.enter="handleSearch"
              v-model="form.linkmanTel"
              placeholder="请选择"
              clearable
            />
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="是否业务员" prop="salesmanFlag">
            <el-select clearable v-model="form.salesmanFlag" placeholder="请选择">
              <el-option :value="0" label="联系人" />
              <el-option :value="1" label="业务员" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item>
            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" class="mr20" @click="handleSearch" icon="el-icon-search" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="重置" placement="top">
              <el-button @click="handleReset" icon="el-icon-refresh-right" />
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import SupplierSelect from '../components/SupplierSelect'

export default {
  components: {
    SupplierSelect
  },
  data() {
    return {
      form: {
        pageNo: 1
      }
    }
  },
  methods: {
    handleSearch() {
      console.log('salesmanFlag', this.form.salesmanFlag)
      this.$emit('search', this.form)
    },
    handleReset() {
      this.$refs.form.resetFields()
      this.$emit('search', this.form)
    },
    handleSelect(value) {
      this.$set(this.form, 'supplierCode', value)
    }
  }
}
</script>